package com.shenmazong.utils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class DateTime {

    public static Date getDate(){
        SimpleDateFormat date = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = null;


        String format = date.format(new Date());
        System.out.println(format);
        try {

            parse = date.parse(format);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return parse;
    }
    public static Date getTime(){
        SimpleDateFormat time = new SimpleDateFormat("HH:mm:ss");
        Date parse = null;

        String format = time.format(new Date());

        try {

            parse = time.parse(format);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return parse;
    }
    public static Date formatTime(String time){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm:ss");
        Date parse = null;



        try {

            parse =simpleDateFormat.parse(time);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return parse;
    }
    public static Date formatDate(String date){
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        Date parse = null;

        try {

            parse =simpleDateFormat.parse(date);
        } catch (ParseException e) {
            e.printStackTrace();
        }
        return parse;
    }
}
